const common = require('./webpack.common')
const { merge } = require('webpack-merge')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyPlugin = require("copy-webpack-plugin")

const config = merge(common, {
  mode: 'production',
  devtool: 'nosources-source-map',
  output: {
    filename: 'bundle.[hash:8].js',
  },
  plugins: [
    new CleanWebpackPlugin(),
    new CopyPlugin({
      patterns: [
        { from: "./public",
          to: "",
          filter: (resourcePath) => {
            if(/\.html$/.test(resourcePath)){
              return false;
            }
            return true;
          }
        },
      ],
    }),
  ]
})

module.exports = config
